import Vue from 'vue'
import VueRouter from 'vue-router'
import Register from '../views/Register.vue'
import QuestionList from "@/views/student/QuestionList";

Vue.use(VueRouter)

const originalPush = VueRouter.prototype.push
VueRouter.prototype.push = function push (location) {
  return originalPush.call(this, location).catch(err => err)
}

const routes = [
    //注册
  {
    path: '/register',
    name: 'register',
    component: Register
  },

    //登录
  { path: '/',  name: 'Login', meta: { name: '登录'}, component: () => import( '../views/Login.vue')  },

    //学生端
  {
    path: '/student',
    name: 'Student',
    component: () => import('../views/Student.vue'),
    children: [
      { path: 'home', name: 'Home', meta: { name: '首页' }, component: () => import('../views/student/Home') },
      { path: 'predicet', name: 'Predicet', meta: { name: '学习计划' }, component: () => import('../views/student/Predicet') },

      { path: 'learningHabit', name: 'LearningHabit', meta: { name: '学习计划' }, component: () => import('../views/student/LearningHabit') },

      // { path: 'learningPlan', name: 'LearningPlan', meta: { name: '智能生成21天计划表' }, component: () => import('../views/student/LearningPlan') },
      {
        path: '/student/learningPlan',
        name: 'learningPlan',
        meta: { name: '智能生成21天计划表' },
        component: () => import('../views/student/LearningPlan')
      },
      { path: 'assessList', name: 'AssessmentList', meta: { name: '评估列表' }, component: () => import('../views/student/AssessmentList') },
      { path: 'PsyList', name: 'PsyList', meta: { name: '心理评估' }, component: () => import('../views/student/PsyList') },
      { path: 'context', name: 'context', meta: { name: '心理评估' }, component: () => import('../views/student/Context') },
      { path: 'psychologicalAssessment', name: 'psychologicalAssessment', meta: { name: '心理评估' }, component: () => import('../views/student/PsychologicalAssessment') },
      { path: 'QuestionList', name: 'QuestionList', meta: { name: '心理评估' }, component: () => import('../views/student/QuestionList') },
      { path: 'person', name: 'Person', meta: { name: '个人中心' }, component: () => import('../views/student/Person')},
      { path: 'Contest', name: 'Contest', meta: { name: '竞赛和课程' }, component: () => import('../views/student/Contest') },

      {
        path: 'Contest',
        name: 'Contest',
        component: () => import('../views/student/Contest'), // 竞赛管理页面
        children: [
          { path: '/student/Contest/StudentProgress', name: 'StudentProgress', meta: { name: '课程进度' }, component: () => import('../views/student/course/StudentProgress')},
          { path: '/student/Contest/StudentCourse', name: 'StudentCourse', meta: { name: '课程成绩' }, component: () => import('../views/student/course/StudentCourse')},
        ]

      },
      // 竞赛管理路由
      {
        path: '/student/competition',
        name: 'Contest',
        component: () => import('../views/student/Contest'), // 竞赛管理页面
        children: [
          { path: 'participation', name: 'CompetitionParticipation', meta: { name: '竞赛参与情况' }, component: () => import('../views/student/competition/CompetitionParticipation')},
          { path: 'awards', name: 'CompetitionAwards', meta: { name: '获奖情况' }, component: () => import('../views/student/competition/CompetitionAwards')},
        ]
      },
    ]
  },

    //教师端
  {
    path: '/teacher',
    name: 'Teacher',
    component: () => import('../views/Teacher.vue'),
    children: [
      { path: 'home', name: 'Home', meta: { name: '首页' }, component: () => import('../views/teacher/Home') },
      { path: 'counselingstats', name: 'CounselingStats', meta: { name: '咨询统计' }, component: () => import('../views/teacher/CounselingStats') },
      { path: 'studlyManagement', name: 'StudlyManagement', meta: { name: '学习管理' }, component: () => import('../views/teacher/StudlyManagement') },
      { path: 'person', name: 'Person', meta: { name: '个人中心' }, component: () => import('../views/teacher/Person')},
      { path: 'course', name: 'Course', meta: { name: '课程信息' }, component: () => import('../views/teacher/Course') },
      { path: 'student', name: 'Student', meta: { name: '学生信息' }, component: () => import('../views/teacher/Student') },
      { path: 'CommentList1', name: 'CommentList1', meta: {name: '心理健康论坛'}, component: () => import('../views/teacher/CommentList1')},
      { path: 'learnProgress', name:'LearnProgress', meta: { name: '学习情况'}, component: () => import('../views/teacher/LearnProgress')},
      // 教师竞赛管理
      {
        path: 'learnProgress',
        name: 'LearnProgress',
        meta: { name: '学习情况' },
        component: () => import('../views/teacher/LearnProgress'),
        children: [
          {
            path: '/teacher/learnProgress/competitionList', // 改为完整路径
            name: 'CompetitionList',
            meta: { name: '竞赛列表' },
            component: () => import('../views/teacher/competition/CompetitionList')
          },
          {
            path: '/teacher/learnProgress/competitionAward', // 改为完整路径
            name: 'CompetitionAward',
            meta: { name: '竞赛列表' },
            component: () => import('../views/teacher/competition/CompetitionAward')
          }
        ]
      },


      // 教师学习习惯
      {
        path: 'learnProgress',
        name: 'LearnProgress',
        meta: { name: '学习情况' },
        component: () => import('../views/teacher/LearnProgress'),
        children: [
          {
            path: '/teacher/learnProgress/Course', // 改为完整路径
            name: 'StudyHabits',
            meta: { name: '课程' },
            component: () => import('../views/teacher/course/Course')
          },
          {
            path: '/teacher/learnProgress/Scores', // 改为完整路径
            name: 'StudentScores',
            meta: { name: '课程进度' },
            component: () => import('../views/teacher/course/Scores')
          }
        ]
      },


      // 教师学习习惯
      {
        path: 'learnProgress',
        name: 'LearnProgress',
        meta: { name: '学习情况' },
        component: () => import('../views/teacher/LearnProgress'),
        children: [
          {
            path: '/teacher/learnProgress/StudyHabits', // 改为完整路径
            name: 'StudyHabits',
            meta: { name: '学生习惯' },
            component: () => import('../views/teacher/feedback/StudyHabits')
          },
          {
            path: '/teacher/learnProgress/StudentGrowth', // 改为完整路径
            name: 'StudentGrowth',
            meta: { name: '学生成长数据' },
            component: () => import('../views/teacher/feedback/StudentGrowth')
          },
          {
            path: '/teacher/learnProgress/StudentScores', // 改为完整路径
            name: 'StudentScores',
            meta: { name: '学生分数' },
            component: () => import('../views/teacher/feedback/StudentScores')
          }
        ]
      },



      // 学习管理子路由
      {
        path: '/manage',
        name: 'Manage',
        component: () => import('../views/teacher/StudlyManagement'), // 确保组件路径正确
        children: [
          { path: 'weak-course', name: 'WeakCourse', meta: { name: '弱项课程' }, component: () => import('../views/teacher/manage/WeakCourse') },
          { path: 'tutoring-plan', name: 'TutoringPlan', meta: { name: '辅导计划' }, component: () => import('../views/teacher/manage/TutoringPlan') },
          { path: 'resources', name: 'Resources', meta: { name: '资源管理' }, component: () => import('../views/teacher/manage/ResourceManagement') },

        ]
      }
    ]
  },
  //管理端
  {
    path: '/manager',
    name: 'Manager',
    component: () => import('../views/Manager.vue'),
    redirect: '/manager/home',  // 重定向到主页
    children: [
      { path: 'home', name: 'Home', meta: { name: '首页' }, component: () => import('../views/manager/Home') },
      { path: 'admin', name: 'Admin', meta: { name: '管理员信息' }, component: () => import('../views/manager/Admin') },
      { path: 'student', name: 'Student', meta: { name: '学生信息' }, component: () => import('../views/manager/Student') },
      { path: 'teacher', name: 'Teacher', meta: { name: '教师信息' }, component: () => import('../views/manager/Teacher') },
      { path: 'adminPerson', name: 'AdminPerson', meta: { name: '管理员个人信息' }, component: () => import('../views/manager/AdminPerson') },
      { path: 'password', name: 'Password', meta: { name: '修改密码' }, component: () => import('../views/manager/Password') },
      { path: 'course', name: 'Course', meta: { name: '课程信息' }, component: () => import('../views/manager/Course') },
      { path: 'competition', name: 'Competition', meta: { name: '竞赛信息' }, component: () => import('../views/manager/Competition') },
      { path: 'studentScore', name: 'StudentScore', meta: { name: '学生成绩信息' }, component: () => import('../views/manager/StudentCourseGrade') },
      { path: 'award', name: 'Award', meta: { name: '学生竞赛获奖信息' }, component: () => import('../views/manager/Award') },
      { path: 'habit', name: 'Habit', meta: { name: '学习习惯信息' }, component: () => import('../views/manager/StudyHabit') },
      { path: 'weakCourse', name: 'weakCourse', meta: { name: '薄弱课程信息' }, component: () => import('../views/manager/WeakCourse') },
      { path: 'surveyQuestion', name: 'SurveyQuestion', meta: { name: '心理测试题信息' }, component: () => import('../views/manager/SurveyQuestion') },
    ]
  }
]

const router = new VueRouter({
  mode: 'history',
  base: process.env.BASE_URL,
  routes
})

export default router
